#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: solution.py 
@version:
@time: 2024/01/22 
"""


def main():
    comments = input().split(",")

    tree = []
    nodes = comments.copy()

    level = 1
    while nodes:
        comment = nodes.pop(0)
        ensure_level_exists(tree, level)
        tree[level - 1].append(comment)
        child_count = int(nodes.pop(0))
        recursive(nodes, level + 1, child_count, tree)

    print_tree(tree)


def ensure_level_exists(tree, level):
    if len(tree) < level:
        tree.append([])


def recursive(nodes, level, child_count, tree):
    for i in range(child_count):
        comment = nodes.pop(0)
        ensure_level_exists(tree, level)
        tree[level - 1].append(comment)
        count = int(nodes.pop(0))
        if count > 0:
            recursive(nodes, level + 1, count, tree)


def print_tree(tree):
    print(len(tree))
    for nodes in tree:
        print(" ".join(nodes))


"""
input

```text
hello,2,ok,0,bye,0,test,0,one,1,two,1,a,0
    ```

output

```text
3
hello test one
ok bye two
a
```
"""
main()
